package com.gx.mvp.net;

import com.gx.mvp.rx.RxSchedulers;
import io.reactivex.Observable;
import java.io.File;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import org.json.JSONArray;
import org.json.JSONObject;

/**
 * Created by Guoxin on 2019-12-05.
 */
public class ApiFactory {

    private static ApiFactory mInstance = new ApiFactory();
    private        ApiManager mApiManager;
    private        ApiService mApiService;

    private ApiFactory() {
        mApiManager = ApiManager.getInstance();
        mApiService = mApiManager.getApiService();
    }

    public static ApiFactory getInstance() {
        return mInstance;
    }

    /**
     * 获取堆栈信息
     * 备注：用于网络请求错误时定位
     *
     * @return
     */
    private String getStackTrace() {
        return Thread.currentThread().getStackTrace()[1].getMethodName();
    }

    /**
     * 登录
     *
     * @param params
     *
     * @return
     */
    //public Observable<LoginData> login(JSONObject params) {
    //    RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), params.toString());
    //    return this.mApiService.login(body).map(new ApiResultFunction<>(params.toString(), getStackTrace())).subscribeOn(RxSchedulers.io());
    //}
}


